#from base import BitsLong
#from base.graph import Triple
#from base.graph.Triple import Triple as Tri
from numbers import Number

from base.graph.Node_Literal import Node_Literal
from base.graph.impl.FastTripleStore import FastTripleStore
from base.graph.impl.GraphMem2 import GraphMem2
from base.java.Arrays import Arrays
import re

from base.java.System import System
from A import A
from ThreadSafeDict import ThreadSafeDict
from ManagerDict import ManagerDict
from base.rdf.ModelFactory import ModelFactory
from base.rdf.impl.CustomCharReader import CustomCharReader
from base.rdf.impl.ModelCom import ModelCom
from base.rdf.impl.NTripleReader import NTripleReader


def readChar(ss):
    ss[0] = 'a'

if __name__ == "__main__":
    # classToDT = {'int': float}
    # r = 5.3
    # isi = isinstance(r, classToDT)
    # print(isi)
    # print(type(r) == int)
    '''
    a = True
    b = 1
    c = 1.3
    print(isinstance(a, bool))
    print(isinstance(b, int))
    print(isinstance(c, float))

    s = 'sdk'
    for i in range(len(s)):
         ch = s[i]
         print(ch)
    
    li = [None for _ in range(1 << 16)]
    Arrays.fill(li, 5, 7, 3)
    
    
    
    s = 'ssd'
    s = s.replace('s', 'k')
    print(s)

    print(s[0:2])

    s = r"&|<|>|\t|\n|\r|\'|\""
    str1 = '<ab><'
    result = re.search(s, str1)
    if result is not None:
        print('---', result.start(), result.end())

    ret = re.match(s, str1)
    #print(ret.start(), ret.end())
    print(ret.groups())
    ret1 = re.findall(s, str1)
    print(type(ret1))
    i = 0
    while True:
        i += 1
        ret = re.match(s, str1)
        start = ret.start()
        end = ret.end()
        print(start, end)
        if i > 2:
            break

    pattern = re.compile(s)
    r = pattern.search(str1)
    if not r: print("(-1, -1)")
    while r:
        print("({0}, {1})".format(r.start(), r.end() - 1))
        r = pattern.search(str1, r.start() + 1)

    #for g in ret.groups():
        #print(g.start(), g.end())
    '''

    '''
    oldElements = [None for _ in range(4)]
    oldElements[0] = 1
    oldElements[1] = 2
    newElements = [None for _ in range(8)]
    System.arraycopy(oldElements, 0, newElements, 1, 4)

    print(newElements)

    print(A.refSelf)
    
    dd = ThreadSafeDict()
    dd.get('thekey')
    dd.set('thekey', 1)
    dd.delete('thekey')
    d2 = ManagerDict()
    d2.deal()
    '''
    #
    # store1 = FastTripleStore()
    # graph = GraphMem2(store1)
    # s = Node_Literal("s")
    # p = Node_Literal("p")
    # o = Node_Literal("o")
    # graph.addSPO(s, p, o)

    s = 'sd'
    sk = []
    # print(s[0])
    # readChar(sk)
    # print(sk)
    # for i in range(5, 10):
    #     print(i)
    reader = CustomCharReader('a.rdf')
    tr = NTripleReader()
    model = ModelCom(ModelFactory.createDefaultModel())
    tr.read(model, reader, None)

    print(model.listObjects())

    ret = reader.read(sk, 0, 1)
    print(sk, ret)

    ret = reader.read(sk, 0, 1)
    print(sk, ret)

    ret = reader.read(sk, 0, 1)
    print(sk, ret)

